<template>
  <div class="box-list-container">
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="登录账号:">
              <el-input v-model="queryParam.loginNum" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="唯一编码:">
              <el-input v-model="queryParam.onlyCode" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="是否禁用:">
              <el-select v-model="queryParam.isDisable" placeholder="请选择">
                <el-option label="是" value="1" />
                <el-option label="否" value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="toggleSearchStatus">
            <!-- <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="是否开启日志:">
                <el-select v-model="queryParam.isOpenLog" placeholder="请选择">
                  <el-option label="是" value="1" />
                  <el-option label="否" value="0" />
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="联系方式:">
                <el-input v-model="queryParam.contact" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="备注:">
                <el-input v-model="queryParam.remarks" placeholder="请输入" />
              </el-form-item>
            </el-col>
          </template>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
            <el-link style="margin-left: 10px;" type="primary" :underline="false" @click="toggleSearchStatus = !toggleSearchStatus">
              {{ toggleSearchStatus ? '收起' : '展开' }}
              <i :class="toggleSearchStatus ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
            </el-link>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          会员列表
        </div>
        <div>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增</el-button>
          <!-- <el-button type="success" icon="el-icon-download">导出</el-button
           -->
        </div>
      </div>
      <!-- 批量操作 -->
      <div v-if="selectedRowList.length" class="batchAction">
        <div class="batchAction-left">
          <el-dropdown>
            <el-button>
              更多菜单 <i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <!-- <el-dropdown-item>
                <div @click="batchDelete"><i class="el-icon-delete" />删除</div>
              </el-dropdown-item> -->
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="batchAction-right">
          已选择
          <span style="font-weight: 700">
            <el-link type="primary" :underline="false">{{ selectedRowList.length }}</el-link>
          </span>项
          <el-link type="primary" :underline="false" style="margin-left: 24px;" @click="onClearSelected">清空</el-link>
        </div>
      </div>
      <el-table ref="table" :data="dataSource" @selection-change="onSelectChange">
        <el-table-column type="selection" width="55" />
        <el-table-column fixed="left" label="序号" width="50" type="index" />
        <el-table-column fixed="left" prop="loginNum" label="登录账号" width="120" />
        <el-table-column prop="expireTime" label="到期时间" width="160">
          <template slot-scope="scope">
            <div :class="[isTimeout(scope.row.expireTime) ? 'color-red' : 'color-blue']">{{ scope.row.expireTime }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="onlyCode" label="唯一编码" width="300" />
        <el-table-column prop="userType" label="是否vip">
          <template slot-scope="scope">
            {{ scope.row.userType === '1' ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column prop="isDisable" label="是否禁用">
          <template slot-scope="scope">
            {{ scope.row.isDisable === '1' ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column prop="isOpenLog" label="开启日志">
          <template slot-scope="scope">
            {{ scope.row.isOpenLog === '1' ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column prop="contact" label="联系方式" />
        <el-table-column prop="createTime" label="创建时间" width="150" />
        <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button type="text" @click="handleView('查看', scope.row)">查看</el-button>
            <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <!-- <el-button type="text" @click="topUp(scope.row.loginNum)">充值</el-button>
            <el-button type="text" @click="resetExpire(scope.row.loginNum)">重置到期</el-button> -->
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row.id)">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
        <div slot="empty" class="emptyBg">
          <img src="@/assets/img/emptyData.png">
        </div>
      </el-table>
      <div class="box-paging">
        <pagination
          v-show="ipagination.total > 0"
          layout="total, sizes, prev, pager, next"
          :total="ipagination.total"
          :page.sync="ipagination.pageNum"
          :limit.sync="ipagination.pageSize"
          @pagination="loadData"
        />
      </div>
    </div>
    <!-- 查看 -->
    <viewDrawerModel ref="modalFormView" />
    <!-- 更新 -->
    <updateModel ref="modalForm" @ok="modalFormOk" />
  </div>
</template>

<script>
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import updateModel from './components/updateModel'
import viewDrawerModel from './components/viewDrawerModel'

export default {
  components: {
    Pagination,
    updateModel,
    viewDrawerModel
  },
  mixins: [listMixin],
  data() {
    return {
      toggleSearchStatus: false,
      url: {
        list: 'MemberUser.aspx?action=GetList',
        delete: 'MemberUser.aspx?action=Delete'
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 到期时间是否超时
    isTimeout(time) {
      return this.$moment(time).isBefore(new Date())
    }
  }
}
</script>

<style lang="scss" scoped>
.color-red{
  color: red;
  // font-weight: 600;
}
</style>

